Neopixels

Neopixels are multicoloured strips of LEDs, where each LED can be individually controlled.

Use neopixels to add impressive light displays or data visualisations to your project


Wire up

The colours of the wires can vary, so check the lettering on the end of the neopixel strip to connect correctly Connect to the Pico as follows:

Wire up
Circuit Pico
5V 3V3
Black GND
DI or DIn GP2 or another GP pin

Add the library

You need to add the neopixel library. Copy neopixel.py from the lib directory on github to the lib directory on the pico:

Add lib

Code

Write this code and download to the Pico.

See code on github
# Test neopixel

import board
import neopixel

# Set the number of pixels connected
num_pixels = 30

# Create the neopixel object
pixels = neopixel.NeoPixel(board.GP22, num_pixels)

# Set the broghtness level (from 0 to 1)
pixels.brightness = 1

# Set the colours of all pixels
pixels.fill((255, 0, 0))

# Set the colours of pixels individually
pixels[0] = (0,255,0) # green
pixels[1] = (0,0,255) # blue
pixels[2] = (255,255,255) # white

Further reading

The library documentation can be found here.

The original library can be found here.